/**
 * @Copyright ®2015 Sinosoft Co. Ltd. All rights reserved.
 * 项目名称 : 网站服务平台
 * 创建日期 : 2017-10-18
 * 修改历史 :
 * 1. [2017-10-18]创建文件 by chenxin
 */
package com.gavinwind.inspay.center.configserver.enviroment;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.config.server.environment.EnvironmentRepository;
import org.springframework.cloud.config.server.environment.NativeEnvironmentRepository;
import org.springframework.cloud.config.server.environment.SearchPathLocator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * 【类或接口功能描述】
 * @author chenxin
 * @date 2017-10-18 下午9:44 
 * @version V1.0
 */
//@Configuration
//@ConditionalOnMissingBean(EnvironmentRepository.class)
//@ConditionalOnProperty("spring.cloud.config.server.databases")
public class DatabasesRepositoryConfiguration {
    @Autowired
    private ConfigurableEnvironment environment;

    @Bean
    public SearchPathLocator searchPathLocator() {
        return new NativeEnvironmentRepository(environment);
    }

    @Bean
    @Primary
    public EnvironmentRepository openEnvironmentRepository() {
        return new DatabasesEnvironmentRepository();
    }
}
